<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <input type="button" value="防抖" id="btn1">
    <input type="button" value="节流" id="btn2">
    <input type="button" value="正常" id="btn3">
</body>
<script>

    const obtn1 = document.querySelector("#btn1")
    const obtn2 = document.querySelector("#btn2")
    const obtn3 = document.querySelector("#btn3")

    let t;
    obtn1.onclick = function(){
        clearTimeout(t)
        t = setTimeout(()=>{
            console.log("hello")
        }, 500);
    }


    let flag = true;
    obtn2.onclick = function(){
        if(flag){
            flag = false;
            setTimeout(()=>{
                console.log("world")
                flag = true;
            }, 500);
        }
    }

    
    obtn3.onclick = function(){
        console.log("hahaha");
    }
    
</script>
</html>